﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;

namespace NJL.Web.Controls
{
    public partial class WUCVisitorSpaceLeft1 : BaseUserControl
    {
        BLL.NJL_USER bllUser = new BLL.NJL_USER();
        Model.NJL_USER modelUser;
        NJL.BLL.NJL_PERSON bllPerson = new BLL.NJL_PERSON();
        NJL.Model.NJL_PERSON modelPerson;
        NJL.BLL.NJL_MYFRIEND bllFriend = new BLL.NJL_MYFRIEND();
        public string isFriend = "";
        NJL.BLL.NJL_MYFRIEND bllMyFriend = new BLL.NJL_MYFRIEND();
        NJL.BLL.NJL_REG_PERSON_VISIT bllPersonVisit = new BLL.NJL_REG_PERSON_VISIT();

        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                DataSet ds = bllMyFriend.GetList(8, "NJL_MYFRIEND.NJL_USER_ID='" + Request.QueryString["uid"] + "'", "NJL_MYFRIEND.CREATE_DATE_TIME desc");
                rptUserFriend.DataSource = ds;
                rptUserFriend.DataBind();
                ds = bllMyFriend.GetList("NJL_MYFRIEND.NJL_USER_ID='" + Request.QueryString["uid"] + "'");
                //litFriendsCount.Text = ds.Tables[0].Rows.Count.ToString();
                ds = bllPersonVisit.GetList(6, "a.NJL_PERSON_ID='" + Request.QueryString["uid"] + "'", "a.CREATE_DATE_TIME desc");
                if (ds.Tables[0].Rows.Count > 0)
                {
                    rptLogUser.DataSource = ds;
                    rptLogUser.DataBind();
                }
            }
           
            if (UserId != "")
            {
                DataSet dsFriend = bllFriend.GetList("NJL_MYFRIEND.FRIEND_USER_ID=" + Request.QueryString["uid"] + " and NJL_MYFRIEND.NJL_USER_ID=" + UserId);
                if (dsFriend.Tables[0].Rows.Count > 0)
                {
                    isFriend = "true";
                }            
            }
            string uid = Request.QueryString["uid"].ToString();
            modelUser = bllUser.GetModel(uid);
            {
                //litQQ.Text = modelUser.QQ;
                //litMobel.Text = modelUser.MOBILE;
                //litUserName.Text = modelUser.USER_NAME;
                litName.Text = modelUser.USER_NAME;
                if (modelUser.INTEGRAL == null)
                {
                    litScore.Text = "0";
                }
                else
                {
                    litScore.Text = modelUser.INTEGRAL.ToString();
                }
            }
            modelPerson = bllPerson.GetModelByUserId(uid);
            if (modelPerson != null)
            {
                litSex.Text = modelPerson.SEX;
                //litBirthday.Text = string.Format("{0:yyyy-MM-dd}", modelPerson.BIRTHDAY);
                if (modelPerson.IMAGE_CODE != "")
                {
                    //imghead.ImageUrl = GetImageUrl(modelPerson.IMAGE_CODE,"U1");
                    Image1.ImageUrl = GetImageUrl(modelPerson.IMAGE_CODE, "U1");
                }
                else
                {
                    Image1.ImageUrl = "~/Images/avatar.jpg";
                    //imghead.ImageUrl = "~/Images/avatar.jpg";
                }
            }
        }
    }
}